<?php

namespace app\admin\validate;

use think\Validate;

class School extends Validate
{
    /**
     * 验证规则
     */
    protected $rule = [
        'name' => 'require|unique:school,name',
        'no'   => 'require|unique:school,no',
    ];
    /**
     * 提示消息
     */
    protected $message = [
        'no.unique'  => '该编号已经存在',
        'name.unique'  => '该名称已经存在',
    ];
    /**
     * 验证场景
     */
    protected $scene = [
        'add'  => ['no','name'],
        'edit' => [],
    ];

    public function __construct(array $rules = [], $message = [], $field = [])
    {
        $this->field = [
            'no'   => __('编号'),
            'name' => __('学校姓名'),
        ];
        parent::__construct($rules, $message, $field);
    }
}
